﻿@model GPS.ENTITYS.CrudModelDHV

@{
    ViewBag.Title = "Chỉnh sửa Học Viên";
}


@using (Html.BeginForm("Edit", "GPS_HocVien", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <h3 class="text-center fdb-title-search-form">Chỉnh sửa thông tin Học Viên</h3>
    <div id="tabs">
        <div id="tabs-1">
            @Html.Hidden("IsEdit", 0)
            <fieldset class="fs_body">
                <legend class="head_title">Thông Tin Học Viên</legend>
                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Mã học viên:
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_MA, new { @class = "form-control", @readonly = "readonly" })
                    </div>
                </div>
                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Họ đệm:<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_HODEM, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.HV_HODEM)
                    </div>

                    <div class="col-md-2 control-label">
                        Tên:<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_TEN, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.HV_TEN)
                    </div>
                </div>
                <div class="row margin-top-05">
                    <div class="col-md-2 control-label text-left">
                        Đơn Vị Đào Tạo:<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @*@Html.DropDownListFor(model => model.HV_DVGTVT_MA, (SelectList)ViewBag.HV_DVGTVT_MAs, string.Empty, new { @class = "form-control", @id = "HV_DVGTVT_MA" })*@
                        @Html.TextBoxFor(model => model.HV_DVGTVT_MA, new { @class = "form-control", @id = "HV_DVGTVT_MA",  @style = "width:100%;max-width:100%;" })
                        @Html.ValidationMessageFor(model => model.HV_DVGTVT_MA)
                        <span id="rDataDVGTVT_MA" style="width:500px"></span>
                        <div class="help-tip">
                            <p>Gõ mã hoặc Tên Đơn vị GTVT để hiển thị danh sách đơn vị GTVT</p>
                        </div>
                    </div>
                </div>
                <div class="row margin-top-05">
                    <div class="col-md-2 control-label text-left">
                        Khóa học:<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.HV_KH_MA, (SelectList)ViewBag.KH_MAs, string.Empty, new { @class = "form-control", @id = "ddlKH_MA" })
                        @Html.ValidationMessageFor(model => model.HV_KH_MA)
                    </div>
                    <div class="col-md-2 control-label">
                        Hạng đào tạo:
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.HV_HANGDT_MA, (SelectList)ViewBag.HV_HANGDT_MAs, string.Empty, new { @class = "form-control" })

                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Ngày sinh:<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_NGAYSINH, "{0:dd/MM/yyyy}", new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.HV_NGAYSINH)
                    </div>

                    <div class="col-md-2 control-label">
                        Số CMTND:<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_SOCMT, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.HV_SOCMT)
                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Ngày Cấp CMT:
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_NGAYCAPCMT, "{0:dd/MM/yyyy}", new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.HV_NGAYCAPCMT)
                    </div>
                    <div class="col-md-2 control-label">
                        Nơi Cấp CMTDN:
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.HV_NOICAPCMT, (SelectList)ViewBag.HV_NOICAPCMTs, string.Empty, new { @class = "form-control" })
                    </div>
                </div>
            </fieldset>
            <br />
            <div id="dialog"></div>
            <fieldset class="fs_body">
                <legend class="head_title">Thông Tin Chi Tiết</legend>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Nơi Thường Trú
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_NOITT, new { @class = "form-control" })
                    </div>

                    <div class="col-md-2 control-label">
                        Nơi TT/ĐV Hành Chính
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_NOITT_DVHC_MA, new { @class = "form-control", @id = "HV_NOITT_DVHC_MA",  @style = "width:100%;max-width:100%;" })
                        <span id="rData" style="width:300px"></span>
                        <div class="help-tip">
                            <p>Gõ mã hoặc Tên Đơn vị  để hiển thị danh sách đơn vị </p>
                        </div>
                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Nơi Thường Trú ĐVHC
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_NOITT_DVHC_DVQL, new { @class = "form-control", @id = "HV_NOITT_DVHC_DVQL", @style = "width:100%;max-width:100%;" })
                        <div class="help-tip">
                            <p>Gõ mã hoặc Tên Đơn vị  để hiển thị danh sách đơn vị </p>
                        </div>
                    </div>

                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Quốc Tịch<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.HV_QUOCTICH_MA, (SelectList)ViewBag.HV_QUOCTICH_MAs, string.Empty, new { @class = "form-control" })

                        @Html.ValidationMessageFor(model => model.HV_QUOCTICH_MA)
                    </div>

                    <div class="col-md-2 control-label">
                        Giới Tính<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.HV_GIOITINH, new List<SelectListItem>
                                {
                                                    new SelectListItem() {Text = "Nam", Value="M"},
                                                    new SelectListItem() {Text = "Nữ", Value="F"}

                                }, "-- Lựa Chọn --", new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.HV_GIOITINH)
                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Nơi Cư Trú
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_NOICT, new { @class = "form-control", @id = "HV_NOICT" })
                    </div>

                    <div class="col-md-2 control-label">
                        Nơi CT/ĐV Hành Chính
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_NOICT_DVHC_MA, new { @class = "form-control", @id = "HV_NOICT_DVHC_MA" ,@style = "width:100%;max-width:100%;" })
                        <span id="rData" style="width:300px"></span>
                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Nơi Cư Trú ĐVHC
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.HV_NOICT_DVHC_DVQL, new { @class = "form-control", @id = "HV_NOICT_DVHC_DVQL" })
                    </div>
                    <div class="col-md-2 control-label">
                        Trạng Thái<span style="color:red;">(*)</span>
                    </div>
                    <div class="col-md-4">
                        @Html.CheckBoxFor(model => model.HV_ACTIVE, new { @class = "checkbox" })
                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Mô Tả
                    </div>
                    <div class="col-md-4">
                        @Html.TextAreaFor(model => model.HV_MOTA, new { @class = "form-group", @rows = 5, @style = "width:100%;max-width:100%;" })
                    </div>
                </div>
            </fieldset>
        </div>
    </div>
    <br />

    <div class="row">
        <div class="col-md-12">
            @*<input type="submit" value="Cập nhật" class="btn btn-info btn-sm" />*@
            <button type="submit" class="btn btn-danger btn-sm">
                <span class="glyphicon glyphicon-floppy-disk"></span> Cập nhật
            </button>
            &nbsp;&nbsp;
            @Html.ActionLink("Quay lại", "Index", null, new { @class = "btn btn-primary btn-sm" })
        </div>

    </div>
}

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

<script src="~/Scripts/datepicker.js"></script>
<script src="~/Scripts/jquery-ui-1.11.4.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/jquery.maskMoney.js"></script>
<script src="~/Scripts/jquery.number.js"></script>
<script src="~/Scripts/jquery.masknumber.js"></script>
<script src="~/Scripts/moment.js"></script>

<script type="text/javascript">
    $(document).tooltip();
    // Voi jQuery 1.9 > thi chi validate gia tri trong active tab
    // Muon validate nhung gia tri trong cac tab khac nua thi dung jquery.validate 1.8.1 or 1.7


    // mask edit cho truong ngay thang (su dung jquery.maskedinput)


    function ToJavaScriptDate(value) {
        if (value != null) {
            var pattern = /Date\(([^)]+)\)/;
            var results = pattern.exec(value);
            var dt = new Date(parseFloat(results[1]));
            return dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + dt.getFullYear();
        }
        return null;
    }
</script>
<script type="text/javascript">
    $("#HV_NGAYSINH").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });

    $("#HV_NGAYCAPCMT").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });


    $("#HV_NGAYSINH").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });
    $("#HV_NGAYCAPCMT").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });

    // cho phep nhap so thap phan (su dung jquery.number)
    //$("#GV_THAMNIENLX").number(true, 2, '.', '');

</script>

@Styles.Render("~/Content/themes/base/css")

<script type="text/javascript">
    $(document).ready(function () {
        $("#HV_NOITT_DVHC_MA").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/GPS_HocVien/AutoCompleteNOICT_DVHC_MA",
                    type: "POST",
                    dataType: "json",
                    data: { term: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.DVHC_TENDAYDU, value: item.DVHC_MA + ':' + item.DVHC_TENDAYDU };
                        }))


                    }
                })
            },
            messages: {
                noResults: "", results: ""
            }
        }).click(function () {
            $(this).val("");
            $(this).autocomplete("search");
        });

        $("#HV_NOITT_DVHC_DVQL").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/GPS_HocVien/AutoCompleteNOICT_DVHC_MA",
                    type: "POST",
                    dataType: "json",
                    data: { term: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.DVHC_TENDAYDU, value: item.DVHC_MA + ':' + item.DVHC_TENDAYDU };
                        }))


                    }
                })
            },
            messages: {
                noResults: "", results: ""
            }
        }).click(function () {
            $(this).val("");
            $(this).autocomplete("search");
        });

        $("#HV_DVGTVT_MA").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/GPS_HocVien/AutoCompleteDVGTVT_MA",
                    type: "POST",
                    dataType: "json",
                    data: { term: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.DVGTVT_TEN, value: item.DVGTVT_MA + ':' + item.DVGTVT_TEN };
                        }))


                    }
                })
            },
            change: function (event, ui) {
                var _val = $("#HV_DVGTVT_MA").val();
                if (_val != null && _val != '') {
                    $.ajax({
                        url: '@Url.Action("getKH_MAs", "GPS_HocVien")',
                        type: 'post',
                        data: {
                            ma_DVGT: _val
                        }
                    }).done(function (response) {
                        // update KH
                        var a = '<option value></option>' + response;   // defaut value
                        $("#ddlKH_MA").html(a);

                    });
                }
            },

            messages: {
                noResults: "", results: ""
            }
        }).click(function () {
            $(this).val("");
            $(this).autocomplete("search");
        });

        //$('#HV_DVGTVT_MA').change(function (e) {
        //    var _val = $(this).val();
        //    alert(_val);
        //});

        @*$("#HV_DVGTVT_MA").blur(function () {
            alert('1');
            var _val = $(this).val();
            if (_val != null && _val != '') {
                $.ajax({
                    url: 'getKH_MAs',
                    type: 'post',
                    data: {
                        ma_DVGT: _val
                    }
                }).done(function (response) {
                    // update KH
                    var a = '<option value></option>' + response;   // defaut value
                    $("#ddlKH_MA").html(a);

                });
                @*$.ajax({
                    url: '@Url.Action("getHV_MA", "GPS_HocVien")',
                    type: 'post',
                    data: {
                        gv_DVGTVT_MA: $('#HV_DVGTVT_MA').val()
                    }
                }).done(function (response) {

                    $('#HV_MA').val(response);
                });
            }

        });*@
    })
</script>
